import Mock from 'mockjs'
import { CONSTANT_OBJ } from '@/utils/constant'
let baseURL
let locationHref = `http://${window.location.hostname}`
if (CONSTANT_OBJ.ENV !== 'prodMaster') {
  baseURL = CONSTANT_OBJ.URL + CONSTANT_OBJ.PREFIX + '/esale-user'
  // baseURL = URL
} else {
  baseURL = locationHref + CONSTANT_OBJ.PREFIX + '/esale-user'
}
// 产品列表查询
Mock.mock(`${baseURL}/v1/api/esale-backend/product/queryByCondition`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE,
    data: {
      total: 2,
      list: [
        { productId: '1', productName: '即享金', productNo: 101 },
        { productId: '2', productName: '即享贷', productNo: 102 }
      ]
    }
  }
})

// 逾期客户列表列表查询
Mock.mock(`${baseURL}/v1/api/esale-pay/repay/overdue/queryByCondition`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE,
    data: {
      total: 3,
      list: [
        { overdueId: '1', loanSerialNo: '202206140707546', customerName: '王小喵', productName: '即享金', loanAmount: 100000, loanTime: '2022-05-22 10:10:10', needRepayAmount: 1365.38, repaidAmount: 120, remainRepayAmount: 200, currentStatus: '1' },
        { overdueId: '2', loanSerialNo: '202206140707547', customerName: '张晓菲', productName: '即享贷', loanAmount: 100000, loanTime: '2022-05-22 10:10:10', needRepayAmount: 1365.38, repaidAmount: 120, remainRepayAmount: 200, currentStatus: '2' },
        { overdueId: '3', loanSerialNo: '202206140707548', customerName: '王开发', productName: '即享贷', loanAmount: 100000, loanTime: '2022-05-22 10:10:10', needRepayAmount: 1365.38, repaidAmount: 120, remainRepayAmount: 200, currentStatus: '3' }
      ]
    }
  }
})

// 还款逾期件撤回分派
Mock.mock(`${baseURL}/v1/api/esale-pay/repay/overdue/assign/cancel`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE
  }
})

// 查询分派受理人
Mock.mock(`${baseURL}/v1/api/esale-user/user/query/assign/acceptors`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE,
    data: {
      total: 3,
      list: [
        { realName: '老王', userName: '1', userId: '222', organizationName: 'xxxxx' },
        { realName: '小王', userName: '2', userId: '333', organizationName: 'xxxxx' },
        { realName: '王小王', userName: '3', userId: '444', organizationName: 'xxxxx' }
      ]
    }
  }
})

// 还款逾期件分派受理人
Mock.mock(`${baseURL}/v1/api/esale-pay/repay/overdue/assign/acceptor`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE
  }
})

// 通过ID查询还款逾期详情
Mock.mock(`${baseURL}/v1/api/esale-pay/repay/overdue/queryById/1`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE,
    data: {
      latestRepayAmount: 2000,
      needRepayAmount: '333233',
      latestRepayDay: '2022-12-23',
      overdueAmount: 12323,
      overdueDays: '3',
      remainRepayAmount: 3434,
      productName: '即享金',
      loanAmount: '23235',
      loanPeriods: 12,
      loanTime: '2022-12-03',
      repayOverdueCustomerInfo: {
        customerName: '王小喵',
        idNbr: '22222222',
        customerPhone: '13555660',
        organPhone: '020-56666',
        organName: 'dsds',
        addressList: [
          { addressType: 'H', province: 'X省', city: 'X市', town: 'X区', street: 'xxx号' },
          { addressType: 'C', province: 'A省', city: 'XA市', town: 'XA区', street: 'xxAx号' }
        ]
      }
    }
  }
})

// 跟踪记录查询
Mock.mock(`${baseURL}/v1/api/esale-pay/repay/follow/queryByCondition`, function () {
  return {
    ...CONSTANT_OBJ.MOCK_RESPONSE,
    data: {
      total: 3,
      list: [
        { overdueId: '1', loanSerialNo: '202206140707546', customerName: '王小喵', acceptorOrgName: '直销分期部一部', createTime: '2022-06-18 10:00:00', followDesc: '广州市天河区' },
        { overdueId: '2', loanSerialNo: '202206140707547', customerName: '张晓菲', acceptorOrgName: '直销分期部二部' },
        { overdueId: '3', loanSerialNo: '202206140707548', customerName: '王开发', acceptorOrgName: '直销分期部三部' }
      ]
    }
  }
})
